<?php
 	function getRequest($sVar,$ret=null){
		if(isset($_REQUEST[$sVar]) && is_array($_REQUEST[$sVar]))
			return checkArrayValue($_REQUEST[$sVar]);
			
		return isset($_REQUEST[$sVar]) ? checksqlstr($_REQUEST[$sVar]) : $ret;
	}
	
	function checksqlstr($getstr){
		//检测输入的参数是否含有sql敏感字符，如果有返回过滤后的符串
		$getstr = trim($getstr);
		if (strlen($getstr) == 0 || is_null($getstr)){
			$result="";
			return $result;
		}

		$pattern = "/法(\s|　)*轮(\s|　)*功|胡锦涛|共产党|基督教|毛席东|泽毛东|东毛席|席东毛|毛主席|席毛主|功法轮|轮法功|反日|日本主义者|台独|台湾独立|基督教|李登辉|自焚|江泽明|藏独|西藏独立|地震预测/i";
		$getstr = preg_replace($pattern, "", $getstr);
		
        $pattern = array(
                '/\biframe\b/i',
                '/\bjavascript\b/i',
                '/\bvbscript\b/i',
                '/\bscript\b/i',
                '/\bselect\b/i',
                '/\binsert\b/i',
                '/\bdelete\b/i',
                '/\bupdate\b/i',
                '/\bdrop\b/i',
                '/\bcreate\b/i',
                '/\bexec\b/i',
                '/\btruncate\b/i',
                '/\bdeclare\b/i'    
        );
		$rep = array_fill(0,count($pattern),'');
		$getstr = preg_replace($pattern, $rep, $getstr);

        $s = array(chr(0), '0x', "'",  '<',    '>',    '   ',    "\r\n", "\n");
        $r = array('',     '',   "''", '&lt;', '&gt;', '&nbsp;', '<br>', '<br>');
        $getstr = str_replace($s, $r, $getstr);

		return $getstr;
	}
	
	function retJson($code=0,$msg='fail'){
		$retarr = array(
			'code'=>$code,
			'info'=>$msg
		);
		return json_encode($retarr);
	}
	